package com.ruimei.util;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

import org.springframework.web.multipart.MultipartFile;

import com.ruimei.UploadFileConfig;

import net.coobird.thumbnailator.Thumbnails;

public class ImagesUtils {
	
	public  File compressPictures(File file, MultipartFile files) throws IOException {	
		Thumbnails.of(files.getInputStream())
		.scale(0.3)
		.outputQuality(0.9)
		.toFile(UploadFileConfig.save+"/"+"compress"+"/"+files.getOriginalFilename());
		File up = new File(UploadFileConfig.save+"/"+"compress"+"/"+files.getOriginalFilename());
		return up;
	}

	public File compressPictures(File file,MultipartFile files,int ramdomInt) throws  IOException{
		Thumbnails.of(files.getInputStream())
				.scale(1.0)
				.outputQuality(1.0)
				.toFile(UploadFileConfig.save+"/"+"compress"+"/"+files.getOriginalFilename());
		File up = new File(UploadFileConfig.save+"/"+"compress"+"/"+files.getOriginalFilename());
		return up;
	}
	
	
	
	

}
